package com.zygh.lz.util;

import java.util.Random;

public class GetRandomUtil {
    /**
     * @param RandMax    最大值
     * @param ExceptNums 不能包含的随机数
     * @return 随机数
     */
    public static int getRandomExcept(int RandMax, int[] ExceptNums) {
        Random rand = new Random();
        int num = rand.nextInt(RandMax);
        while (true) {
            int have = 0;
            for (int i = 0; i < ExceptNums.length; i++) {
                if (num == ExceptNums[i]) {
                    have = 1;
                }
            }
            if (have == 0) {
                return num;
            }
            num = rand.nextInt(RandMax);
        }
    }


}
